config.output.devtoolModuleFilenameTemplate   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
const webpack = require("webpack");
2
const path = require("path");
3
const HtmlWebpackPlugin = require("html-webpack-plugin");
4
const DashboardPlugin = require("webpack-dashboard/plugin");
5
const nodeEnv = process.env.NODE_ENV || "development";
6
const isProd = nodeEnv === "production";
7
8
var config = {
9
    devtool: isProd ? "hidden-source-map" : "source-map",
10
    context: path.resolve("./src"),
11
    entry: {
12
        app: "./index.ts",
13
        vendor: "./vendor.ts",
14
    },
15
    output: {
16
        path: path.resolve("./dist/browser"),
17
        filename: "[name].bundle.js",
18
        sourceMapFilename: "[name].bundle.map",
19
        devtoolModuleFilenameTemplate: function (info) {
20
            return "file:///" + info.absoluteResourcePath;
21
        }
22
    },
23
    module: {
24
        rules: [
25
            {
26
                enforce: "pre",
27
                test: /\.ts?$/,
28
                exclude: ["node_modules"],
29
                use: ["awesome-typescript-loader", "source-map-loader"]
30
            },
31
            {test: /\.html$/, loader: "html-loader"},
32
            {test: /\.css$/, loaders: ["style-loader", "css-loader"]}
33
        ]
34
    },
35
    resolve: {
36
        extensions: [".ts", ".js"]
37
    },
38
    plugins: [
39
        new webpack.DefinePlugin({
40
            "process.env": {
41
                // eslint-disable-line quote-props
42
                NODE_ENV: JSON.stringify(nodeEnv)
43
            }
44
        }),
45
        new HtmlWebpackPlugin({
46
            title: "Base JavaScript SDK",
47
            template: "!!ejs-loader!src/index.html"
48
        }),
49
        new webpack.optimize.CommonsChunkPlugin({
50
            name: "vendor",
51
            minChunks: Infinity,
52
            filename: "vendor.bundle.js"
53
        }),
54
        new webpack.optimize.UglifyJsPlugin({
55
            compress: {warnings: false},
56
            output: {comments: false},
57
            sourceMap: true
58
        }),
59
        new DashboardPlugin(),
60
        new webpack.LoaderOptionsPlugin({
61
            options: {
62
                tslint: {
63
                    emitErrors: true,
64
                    failOnHint: true
65
                }
66
            }
67
        }),
68
    ],
69
    devServer: {
70
        contentBase: path.join(__dirname, "dist/browser"),
71
        compress: true,
72
        port: 3000,
73
        hot: true
74
    }
75
};
76
77
module.exports = config;
78